<%-- 
    Document   : add
    Created on : Nov 22, 2014, 9:57:48 PM
    Author     : jostri
--%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>  

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title><fmt:message key="machine.addNew" /></title>
    </head>
    <body>
        <div class="container">
            <c:if test="${null != machine}">
                <h2><fmt:message key="machine.addNew" /></h2>

                <c:url var="saveUrl" value="/machine/add" />
                <form:form method="POST" role="form" action="${saveUrl}" class="form-horizontal" modelAttribute="machine" commandName="machine">
                    <spring:bind path="code">
                        <div class="form-group ${status.error ? 'has-error' : ''}">
                            <form:label path="code" class="control-label col-sm-2"><fmt:message key="machine.code" />:</form:label>
                                <div class="col-sm-10">
                                <form:input path="code" class="form-control"  />
                            </div>
                            <form:errors path="code" class="control-label col-sm-4"  />
                        </div>
                    </spring:bind>
                    <spring:bind path="brand">
                        <div class="form-group ${status.error ? 'has-error' : ''}">
                            <form:label path="brand" class="control-label col-sm-2"><fmt:message key="machine.brand" />:</form:label>
                                <div class="col-sm-10">
                                <form:input path="brand" class="form-control"  />
                            </div>
                            <form:errors path="brand" class="control-label col-sm-4"  />
                        </div>
                    </spring:bind>
                    <spring:bind path="model">
                        <div class="form-group ${status.error ? 'has-error' : ''}">
                            <form:label path="model" class="control-label col-sm-2"><fmt:message key="machine.model" />:</form:label>
                                <div class="col-sm-10">
                                <form:input path="model" class="form-control"  />
                            </div>
                            <form:errors path="model" class="control-label col-sm-4"  />
                        </div>
                    </spring:bind>
                    <spring:bind path="yearOfProduction">
                        <div class="form-group ${status.error ? 'has-error' : ''}">
                            <form:label path="yearOfProduction" class="control-label col-sm-2"><fmt:message key="machine.yearOfProduction" />:</form:label>
                                <div class="col-sm-10">
                                <form:input id="datepicker" path="yearOfProduction" class="form-control"/>
                            </div>
                            <form:errors path="yearOfProduction" class="control-label col-sm-4"  />
                        </div>
                    </spring:bind>

                    <div class="form-group">        
                        <div class="col-sm-offset-2 col-sm-9">
                            <button type="submit" class="btn btn-default"><fmt:message key="save" /></button>
                            <a href="<c:url value="/machine/index" />" onclick="return confirm('<fmt:message key="cancel.confirm" />')"><fmt:message key="machine.cancelchanges" /></a>
                        </div>
                    </div>

                </form:form>
            </c:if>
        </div>
    </body>
</html>
